#include "Board.h"

Board::Board()
	: BaseObject()
{}

void Board::Init()
{
	m_iMeshIndex=BOARD_MESH;
	m_iType = BOARD;
	m_home[0].index=FS3;
	m_home[1].index=YBOX;
	m_home[2].index=PC;
	m_home[3].index=WEE;

	//numbers where player enters safe zone
	m_safeEntrance[FS3]=32;//FS3 fixed;
	m_safeEntrance[YBOX]=2;//YBOX;
	m_safeEntrance[PC]=17;//PC;
	m_safeEntrance[WEE]=47;//WEE Fixed;


	
	int xRows=0, zRows=0;
	for(int i=0;i<g_iallBoardSpots;i++)
	{
		//Setup the Board with positions. 
		//using a formula which was inspired by dean walker
		//I changed the "y" part of the formula to Z
		/*m_boardSpots[i].pos.x=((i%16)*35);
		m_boardSpots[i].pos.y = 30.0f;
		m_boardSpots[i].pos.z=((i/16)*35);*/
		//add 16 squares everytime
		if(i<=g_iYboxSide)
		{
			//go across the x axis for 16 spots
			m_boardSpots[i].pos=set(-255+(xRows*34.0), 25.0f, 264.0f); //z was :240.0f);
			zRows=0;
		}
		else if(i <=g_iPCSide)
		{
			xRows=0;
			//got up on the z for 16 spots
			m_boardSpots[i].pos=set(255, 25.0f, 264.0f-(zRows*34.0));

		}
		else if(i<=g_iFS3Side)
		{
			zRows=0;
			//go across the x axis for 16 spots
			m_boardSpots[i].pos=set(255-(xRows*34.0), 25.0f, -246.0f); //z was 240
		}
		else if(i <=g_iWeeSide)
		{
			xRows=0;
			//got up on the z for 16 spots
			m_boardSpots[i].pos=set(-255, 25.0f, -246.0f+(zRows*34.0));

		}
		else if(i<68)
		{
			zRows=0;
			m_boardSpots[i].pos=set(-187, 25.0f, 264.0f-(xRows*34.0));
		}
		//this is home
	/*	else if(i<69)
		{
			xRows=1;
			m_boardSpots[i].pos=set(-187+(xRows*34.0), 25.0f, 26.0f);
		}
		else if(i<70)
		{
			xRows=1;
			m_boardSpots[i].pos=set(-153, 25.0f, 26.0f+(xRows*34.0f));
		}*/
		//TODO add home positions on boards for each player
		//not sure how the formla worked so did this
		m_boardSpots[i].index=i;
		xRows++;
		zRows++;

	}
}